package singleton;

public class MainTest3 {
    public static void main(String[] args) throws InterruptedException {
        String num1 = "1";
        String num2 = new String("1");
        String num3 = num1;
        Integer i1 = new Integer(1);
        int i2 = 1;
        System.out.println(num1 == num2);
        System.out.println(num1.equals(num2));
        System.out.println(num1 == num3);
        System.out.println(num1.equals(num3));
        System.out.println(i1 == i2);
        System.out.println(i1.equals(i2));

        System.out.println("-------------");
        for (int i = 0; i < 3; i++) {
            Thread t1 = new Thread(()-> {
                Person per1 = Person.getPerson2();
                System.out.println(per1.hashCode());
            });
            t1.start();

            Thread t2 = new Thread(()-> {
                Person per2 = Person.getPerson2();
                System.out.println(per2.hashCode());
            });
            t2.start();

            t1.join();
            t2.join();
            System.out.println("-------------");
        }
    }
}
